library(data.table)
library(latex2exp)
rm(list=ls())
#
DF <- readRDS(paste0("Tables/CF_BLPdata/SDpar/CF_BLPdata_simul_Domestic_pub_param_all.rds"))
setnames(DF,new=c("SDdom","v","BLP","EHA"))
DF[,SDdom := SDdom/100]
yrng <- c(0,9)
#
pdf(file="Graphs/CF_BLPdata/SDdomestic_plot.pdf",height=4,width=7)
par(mar=c(4,5,1,1))  #bottom, left, top and right
my.darkgray <- adjustcolor("black",0.7)
DF[v==3,plot(SDdom,BLP,ylim=yrng,xlim=c(0,2),
               xlab=TeX("SD ($\\sigma$) of domestic"),
               ylab =TeX("Change in domestic share ($\\Delta S$)"),
               type="l",col=my.darkgray,xaxs="i",yaxs="i")] #BLP setting
litvals = c(0.03,.34,0.72,1.72)
points(litvals,DF[v==3]$BLP[which(DF[v==3]$SDdom %in% litvals)],pch=16,col=my.darkgray)
abline(v=litvals,lty=3)
mtext(c("C&G","Diff IV","R&V ii","R&V i"),at=litvals,line=0)
DF[v==2,lines(SDdom,BLP,col=my.darkgray)] # beta het
points(litvals,DF[v==2]$BLP[which(DF[v==2]$SDdom %in% litvals)],pch=15,col=my.darkgray)
DF[v==2,lines(SDdom,EHA,col="black")] #CES
text(1.5,5.75,"Mixed Logit",pos=4,col=my.darkgray)
text(1.9,7.75,"EHA",pos=1,col="black")
text(1,2.5,TeX("$\\beta$ heterogeneity"),col=my.darkgray)
dev.off()
